I. Field of the Invention
The present invention relates to a method for locating the transitions between the elements of a bar code.
II. Prior Art and Other Considerations
In this description and the following claims, the expression xe2x80x9cbar codexe2x80x9d encompasses also xe2x80x9cstackedxe2x80x9d codes, that is, with more stacked bar sequences.
As known, a bar code is an optical code, printed or otherwise marked on a support, for example a label, a package, etc., consisting of a sequence of dark, typically black, rectangular elements called bars, separated by light, typically white rectangular elements called spaces. The sequence of elements is bounded at both sides by much larger zones, called xe2x80x9cquite zonesxe2x80x9d.
The desired information is coded in the number of elements present and/or in the width of each of them. More in particular, a system for coding information through bar codes provides for an alphabet whose symbols are bars and spaces having different widths, typically multiple of a fundamental width called the code xe2x80x9cmodulexe2x80x9d.
The operations needed to read the xe2x80x9cwordxe2x80x9dxe2x80x94that is, the set of symbols of said alphabetxe2x80x94represented by a specific bar code essentially comprise the code illumination, the detection of the light diffused by it through a suitable photodetector, its conversion into an electrical signal, the processing of the electrical signal and its intepretation, or decoding.
The light source can comprise LEDs or lasers, whereas the photodetecting element can comprise a single photodiode, a linear or matrix CCD (Charge Coupled Device) or C-MOS (Complementary Metal Oxide Semiconductor). Moreover, the bar code can be read both by fixed and portable readers. Furthermore, part of the operations for processing the electrical signal and for interpreting and decoding it can be carried out at a remote station.
In all of the above mentioned types of readers, at the output of the photodetector an analog electrical signal is obtained, referred to as xe2x80x9canalog video signalxe2x80x9d in the following description, which reproduces the reflectance modulations of the elements forming the code along a scan line, or xe2x80x9cscanxe2x80x9d, of the same code. In fact, the light with which the code is illuminated is absorbed by the bars and reflected by the spaces. Thus, the analog video signal has an alternate pattern with peaks at the spaces, valleys at the bars and rising and falling edges at the transitions between bars and spaces, and vice versa.
In the prior art, the subsequent processing for decoding the bar code can occur directly on the analog video signal, or prior to said subsequent processing, the analog video signal can be sampled, thus obtaining a xe2x80x9csampled video signalxe2x80x9d which, of course, maintains said features. Typically, the processing on the analog video signal is carried out with hardware components, while processing on the sampled video signal is carried out via software.
In the following description and attached claims, the expression xe2x80x9csampled signalxe2x80x9d encompasses also its software representation.
Moreover, the not further qualified expression xe2x80x9cvideo signalxe2x80x9d is used to indicate an indifferently analog or sampled video signal, whereasxe2x80x94where importantxe2x80x94a video signal shall be further qualified.
The ideal alternate pattern of the video signal is however subject to several non-ideal factors.
A first non-ideal factor is due to the fact that the smaller the elements, that is to say, the higher the code resolution, the less marked the respective peaks or valleys of the signal.
An analogous non-ideal factor is present in low contrast codes, that is to say, in which the difference of luminosity between bars and spaces is small, for example due to the nature of the support on which the code is reproduced. The measure of a code contrast is expressed by its xe2x80x9cPCSxe2x80x9d (Printed Contrast Signal), defined as (Vwxe2x88x92Vb)/Vw, where Vw is the white peak voltage and Vb is the black peak voltage.
Another non-ideal factor is represented by the noise, of electronic nature, due to the reader components, and of ambient nature, due for example to fluctuations in the code illumination.
During the code recognition, said non-ideal factors of the video signal along the scan line may bring to xe2x80x9cskippingxe2x80x9d one or more narrow elements adjacent wider elements or vice versa, to recognising as elements respectively peaks or valleys that instead are due to noise.
Moreover, the acquisition signal may reflect stains, abrasions, slavering or other damages present in some points of the support bearing the code. To prevent the errors caused thereby, a plurality of scans along different code lines is usually carried out during the reading of a bar code.
Another non-ideal factor may be represented by the uneven envelope, typically bell-wise, of the video signal along the scan line, such that at the edges of the code the peaks or the valleys, respectively, have a lower intensity than at the central portion of the code. An uneven envelope may be caused, for example, by the different illumination of the various code portions, in particular in readers where the entire code width is illuminated simultaneously, typically through a series of LEDs, and/or by the losses at the edges of the photodetector, in particular in the above-cited linear sensors.
In the processing and decoding of the video signal, it is essential to be able to establish with great precision the width of the bar code elements.
Among the known methods for evaluating the width of the bar code elements, some are based on locating the transitions between the elements of the code, from which the width of the same elements is then obtained.
However, said known methods for locating the transitions between the bar code elements, implemented both through hardware and software, are quite complex and such as to require the use of many components, or the use of large-capacity memories, of multipliers and microprocessors having a high computational capability, such as DPSs (Digital Signal Processors).
The technical problem at the basis of the present invention is that of allowing locating the transitions between the elements of a bar code in a quick and reliable manner also in readers having limited resources for processing the video signal.
In a first aspect thereof, the invention relates to a method for locating the transitions between the elements of a bar code, comprising the steps of:
a) providing a video signal representative of the intensity of light diffused by the code as a function of the position along a scan line of the code,
b) carrying out at least one low-pass filtering of the video signal (S) for obtaining a respective filtered signal (Fa, Fb, Fc),
c) carrying out at least one comparison between a first comparison signal (A) selected between the video signal (S) and a first filtered signal (Fa, Fb), and a second comparison signal (B), being a filtered signal (Fb, Fc), the second comparison signal (B) being more strongly filtered than the first comparison signal (A), recognising the crossings between the compared signals as transitions between elements of the code at the respective positions.
In this description, the expression xe2x80x9cmore strongly filteredxe2x80x9d is used to indicate the signal filtered with a lower cut-off frequency, and in this meaning the video signal is regarded as filtered with an infinite cut-off frequency.
In fact, the Applicant has recognised that the low-pass filtering has the effect of reducing the peak-to-valley dynamics of the video signalxe2x80x94in a way that is inversely related to the filtering cut-off frequencyxe2x80x94still maintaining its mean value.
At the same time, the low-pass filtering advantageously has the effect of suppressing high-frequency noise.
Therefore, the video signal and a filtered version thereof, as well as two versions thereof filtered with different cut-off frequencies, thus cross each other exactly in high slope zones around the mean value, that is to say, at the rising and falling edges present in the video signalxe2x80x94which as said accurately represents the waveform of the luminous intensityxe2x80x94at the transitions between bars and spaces.
Locating the transitions is thus provided by a simple comparison operation between the homonymous values of the two signals, that is, between the values that the two signals (analog signals, sampled/numerical signals or their software representation) have at the same position in the scan line.
Moreover, it must be noted that knowing the transitions between bars and spaces is sufficient to recognise the word represented by the bar code since the element widths are obtained from the distance between the transitions, obtained for example by subtracting the respective coordinates of position, and the element type is obtained by considering that a bar code always begins (and ends) with a bar, and that the element types alternate.
The recognition of the word represented by the code can be carried out at the same time as the execution of the comparison, or afterwards.
The above method exhibits the advantages of a precise, stable, reliable, quick and repeatable processing.
The above method also exhibits the advantage that it can be implemented both with analog hardware components, and with digital hardware components, and via software.
In a first embodiment, the video signal is an analog video signal, and the filtering is an analog filtering.
In this case, the step c) of comparison can be carried out on the analog signals.
As an alternative, it can be provided to sample the comparison signals, and to carry out the step c) of comparison on the sampled comparison signals.
In order to limit the phase shift between the comparison signals, the analog filtering is preferably carried out with an almost constant group delay.
In a second embodiment, the video signal is a sampled video signal, and the filtering is a digital filtering.
Preferably, the digital filtering is of the linear phase FIR type.
A filtering of this type is equivalent to performing a weighed average of the intensity values of a certain numberxe2x80x94called xe2x80x9corderxe2x80x9d of the filteringxe2x80x94of samples among the considered sample and those adjacent to it. As the number of samples increases, the filtering intensity increases. The samples can be all subsequent, all preceding, or a combination thereof.
Being based on local averages, the method is i.a. suitable for sampled video signals with variable envelope, as those generated by linear sensors.
It must be noted that the absence of filtering, that is, the use, in step c), of the sampled video signal provided in step a), can also be regarded as an order 1 filtering. This may be particularly advantageous in a parametrical implementation.
More preferably, the filtering is of the equal-coefficient FIR type.
In other words, the samples are averaged with a non-weighed averaging operation. This allows reducing the multiplication operations, thus simplifying the digital circuit or the software, quickening the computation.
Even more preferably, the filtering is of the unitary-coefficient FIR type.
This allows totally avoiding the burdensome multiplication operations, thus making a hardware multiplier superfluous, and further simplifying the software. Thus, the filtering operation is quick, for example allowing the method to be implemented through a microcontroller having moderate processing capability.
Even more advantageously, the filtering is of the FIR type, of an order equal to a power of the base in which the sampled video signal is expressed, in particular, to a power of 2.
This provision allows quickening the filtering even more since the division by the number of samples can consist in a digit-shifting operation, in particular a bit-shifting operation, for example through a shift register or an equivalent software processing.
In a particularly preferred way, the filtering is carried out sample by sample during execution of the comparison step.
This allows dramatically reducing the required memory capacity.
In both embodiments, for each comparison of step c) the method can further comprise the steps of:
d) regarding a transition recognised in step c) as valid when in at least one position preceding the subsequent transition in the opposed direction recognised in step c), the absolute value of the difference between the comparison signals is greater than a preselected threshold quantity.
The expression xe2x80x9cdirectionxe2x80x9d of a transition is used to indicate whether the transition is falling, that is, the first comparison signal changes from higher than the second comparison signal to lower than it, or rising, that is, the first comparison signal changes from lower than the second comparison signal to higher than it.
In this way, a hysteresis is introduced in the recognition of the transitions, subordinating said recognition to crossing of a thresholdxe2x80x94respectively higher or lower than the second comparison signalxe2x80x94being checked, so as to prevent recognising the small ripples due to noise as transitions.
In step d), the crossing check, that the difference absolute value is greater than the threshold quantity, can be carried out by providing, for the positions considered, a reference signal having an intensity corresponding to the intensity of the second comparison signal, increased or respectively decreased by the threshold quantity, and comparing the comparison signal with the reference signal.
Moreover, advantageously, the threshold quantity is variable.
In particular, the falling threshold quantity for positions corresponding to points of the code quite zones is greater than the threshold quantity for positions within the code.
The expression xe2x80x9cquite zonesxe2x80x9d is used to indicate the extended white zones present at the edges of a bar code.
In this way, the fact that the signal/noise ratio in the quite zones is typically less than within the code is taken into account.
The quite zone boundaries can be identified with known code localisation methods.
However, the threshold crossing provided for in step d) inherently brings to identifying the quite zone boundaries.
If the code is to be localised only, it is sufficient to provide, for each comparison of step c), the steps of:
e1) rejecting all transitions recognised in step c) corresponding to positions preceding the first position wherein the difference between the first comparison signal and the second comparison signal is greater than a preselected threshold quantity, except for the transition corresponding to the immediately preceding position, and
e2) rejecting all transitions recognised in step c) corresponding to positions subsequent to the last position wherein the difference between the first comparison signal and the second comparison signal is greater than the preselected threshold quantity, except for the transition corresponding to the immediately subsequent position.
Moreover, when in step b) at least two filtering operations are carried out, and in step c) at least two comparisons are carried out, the method can further comprise the steps of:
f1) comparing the sets of transitions obtained in the comparisons of step c), and
f2) selecting the most suitable set of transitions for decoding.
As an alternative, all sets of transitions obtained in the comparisons of step c) are provided for decoding.
In a particularly preferred embodiment, increasingly strongly filtered signals, including the absence of filtering, are compared in pairs, wherein each signal filtered with intermediate strength can be subject to two comparisons.
The various comparisons are preferably carried out in parallel, sample by sample.
As an alternative or in addition, the method can further comprise the steps of:
g) repeating at least once the previous steps for a respective video signal of a subsequent code scan,
g11) comparing the sets of transitions obtained in the comparisons of step c), and
g12) selecting the most suitable set of transitions for decoding.
By thus providing an analogous processing of signals corresponding to different scan lines, the method allows rejecting apparent transitions, due for example to code impurities in some areas, or to temporary reading errors, caused for example by imperfection in the code focusing, unevenness of the ambient light, and so on.
Alternatively to steps g11, g12, all sets of transitions obtained in the comparisons of step c) can be provided for decoding.
As an alternative or in addition, the further following steps can be comprised:
g) repeating at least once the previous steps for a respective video signal of a subsequent code scan,
g21) evaluating statistical parameters relating to the video signal and/or to the sets of recognised transitions, and
g22) setting the operating parameters for a subsequent iteration based on the statistical parameters evaluated in the previous iteration.
By providing a feedback during the processing of signals corresponding to different lines along the code, the method is extremely reliable, as it can be auto-controlled.
In particular, the statistical parameters can comprise the absolute minimum, the absolute maximum and the peak-to-peak level of the digital video signal, the module and the PCS of the optical code, and the minimum signal/noise ratio of the digital video signal.
This statistical information can be used to assign the cut-off frequency pairs to be usedxe2x80x94in particular the FIR filtering ordersxe2x80x94, the number of comparisons to be carried out and the values of the threshold quantity.
As it has been seen, the above method is particularly suitable to be implemented through a processing program, as it is very flexible in terms of parameterisation, design, upgrading and testing.
In the present description and attached claims, the expression xe2x80x9cprocessing programxe2x80x9d refers to a software suitable to be executed both on a computer and on a microcontroller.
Thus, in a second aspect thereof, the invention relates to a processing program comprising program code means suitable to carry out the steps of the above method when the program is executed on a computer.
In a particularly preferred way, the program is embodied in a microcontroller.
Since the method illustrated above requires simple operations, a low-performance microcontroller is sufficient, with further advantages in terms of costs
As an alternative, in particular when the recognising of the word represented by the code occurs at a remote station from the bar code reader, the program is stored in a computer memory, embodied in a read-only memory or carried on a carrier electrical signal, namely when broadcast on a computer network, among which the Internet.
In another aspect thereof, the invention further relates to an electronic circuit suitable to carry out the steps of the above method.
The electronic circuit can comprise only analog components, only digital components, or both analog and digital components.
In another aspect thereof, the invention further relates to a bar code reader comprising a microcontroller or a digital circuit embodying the above method.